/*
 * Merger.h
 *
 *  Created on: 2010-9-14
 *      Author: wenjian
 */

#ifndef MERGER_H_
#define MERGER_H_

#include "../../../commons.h"
#include "../../../gdiplus/gdraw.h"
#include "Shape.h"

using namespace Ed;

namespace S {

  class Merger: public S::Shape{
  //class Merger: public Ed::Elements {
    public:
      Merger();
      virtual ~Merger();

      /**
       * 类型ID
       */
      static unsigned long ClassId;

      /**
       * 类型检查
       */
      virtual bool isInstanceOf(unsigned long classId){
        return Merger::ClassId == classId;
      }

      virtual void createPath();

      virtual void draw(Gdiplus::Graphics* g);

//      virtual const Gdiplus::RectF* getBoundRect();

      /**
       * 增量移动到目标位置
       */
      virtual void moveBy(real dx, real dy);

      /**
       * 检查是否包含点(x, y)
       */
      virtual bool intersects(real x, real y);

      virtual bool intersects(Ed::Element* e);

      /**
       * 是合并器
       */
      virtual bool isMerger(){
        return true;
      }

      /**
       * 改变大小
       */
      virtual void adjustSize(real dx, real dy, int cpIndex);


      /**
       * 添加图形
       */
      void addShapes(const std::vector<AbstractElement*>* els);


      const vector<Shape*>* getShapes(){
        return (const vector<Shape*>*)shapes.getAbstractElements();
      }

      /**
       * 清除被组合的图形
       */
      void clear(){
        shapes.clear();
      }

      /**
       * 设置shapes的Layer
       */
      void setLayer(AbstractLayer* l){
        Shape::setLayer(l);
        shapes.setLayer(l);
      }

    private:
      Elements shapes;
  };

}

#endif /* MERGER_H_ */
